<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <title></title>
    <link rel="stylesheet" href="/static/css/common.css" />
 <script src="/static/jquery/jquery-1.8.2.js"></script>
</head>
<body>

    <div class="pg-header">
        <div class="header-menu">
            <a href="/" class="digg-logo"></a>
            <a class="tb active" href="">全部</a>
            <a class="tb" href="">24区</a>
            <a class="tb" href="">段子</a>
            <a class="tb" href="">图片</a>
            <a class="tb" href="">问答</a>
        </div>
        <div class="header-search">
            <a href="" class="tb">注册</a>
            <a href="" class="tb">登录</a>
        </div>


    </div>
    <div class="pg-body">
        <div class="content-L">
            <div class="nav-top-area" style="margin-bottom:0px">
                <a href="#">
                    <span class="n1"></span>
                    <span class="n2">发布</span>
                </a>

            </div>
        {% for item in data %}
        <a href="{{ item.url }}">{{ item.title }}</a><br />
        {{ item.summary }}<br />
        <!--点赞功能，点击则数字加1，页面不刷新，用ajax来实现;Favor()函数有两个参数，this表示点击的标签，item.id表示哪条新闻-->
        <a href="#" onclick="Favor(this,{{ item.id }});">good {{item.favor_count}}</a>
        <a href="#" onclick="Relay(this,{{ item.id }});">relay {{ item.replay_count }}</a>
        {{ item.create_date|date:"Y-m-d H:i:s" }}<br />
        {% endfor %}
        </div>
        <div class="content-R">

        </div>
    </div>
    <div id="pg-footer" style="position:static;">
            <a href="#">关于我们</a>
            &nbsp;|&nbsp;

            <a href="#">联系方式</a>
            &nbsp;|&nbsp;
            **科技有先公司
    </div>





<script type="text/javascript">

    function Favor(doc,id){
    console.log(id)
        $.ajax({
            url: '/bbs/addfavor/',
            data: { nid:id },
            type: 'POST',
            success:function(callback){
                var obj = jQuery.parseJSON(callback);
                var temp = 'good'+ obj.data;
                $(doc).text(temp);

            }
        }
        );
    }
</script>


</body>
</html>